/*Copyright (C) 2013-2022 LZE*/
#include<bits/stdc++.h>
#define fo(x) freopen(#x".in", "r", stdin); freopen(#x".out", "w", stdout);
#define INF 0x7fffffff
#define mod 1000007
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int N = 2000010;
const int M = 2000010;
ll T, n, m;
struct Edge {
    ll next, to, w, T;
    Edge() {}
} edge[M];
ll head[N], cnt = 0;
ll num = 0;
void add(ll u, ll v, ll w, ll t) {
    edge[++cnt].to = v;
    edge[cnt].w = w;
    edge[cnt].next = head[u];
    edge[cnt].T = t;
    head[u] = cnt;
}
ll hash_(ll x) {
    return ((114514 + x) * 1919810 % mod + mod) % mod;
}
void hash_table_add(ll x) {
    ll hash_val = hash_(x);
    for(ll i = head[hash_val]; i; i = edge[i].next) {
        if(edge[i].w == x) {
            edge[i].T++;
            return;
        }
    }
    num++;
    add(hash_val, mod + num, x, 1);
}
void search(ll x) {
    ll hash_val = hash_(x);
    for(ll i = head[hash_val]; i; i = edge[i].next) {
        if(edge[i].w == x) {
            printf("%lld\n", edge[i].T);
            return;
        }
    }
    printf("0\n");
}
int main() {
#ifdef LOCAL
    fo(debug_data)
#endif
    scanf("%lld%lld", &n, &T);
    ll tmp;
    for(ll i = 1; i <= n; i++) {
        scanf("%lld", &tmp);
        hash_table_add(tmp);
    }
    while(T--) {
        scanf("%lld", &tmp);
        search(tmp);
    }
    return 0;
}
